﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Catch.ISQLServerDAL;
using Catch.SQLServerDAL;
using System.Reflection;
using System.Configuration;
using Catch.AccessCheck;
using System.Xml;
using System.Security.Cryptography;
using System.IO;
using TongTech.TLQ62;
using System.Diagnostics;

namespace TestServer
{
    public partial class Form1 : Form
    {
        #region 配置信息
        /// <summary>
        /// 数据库类型
        /// </summary>
        private readonly string TypeName = "Catch.SQLServerDAL." + ConfigurationManager.AppSettings["SQLTYPE"];
        /// <summary>
        /// 默认值，不改变
        /// </summary>
        private readonly string Path = "Catch.SQLServerDAL";
        /// <summary>
        /// 保存文件路径
        /// </summary>
        private readonly string savepath = ConfigurationManager.AppSettings["SAVEPATH"].ToString();
        /// <summary>
        /// 根节点
        /// </summary>
        private readonly string root = ConfigurationManager.AppSettings["root"].ToString();
        /// <summary>
        /// 产品节点
        /// </summary>
        private readonly string product = ConfigurationManager.AppSettings["product"].ToString();
        /// <summary>
        /// 节点内容
        /// </summary>
        private readonly string[] node = ConfigurationManager.AppSettings["node"].ToString().Split(',');
        /// <summary>
        /// 多少秒执行一次
        /// </summary>
        private readonly int miao = int.Parse(ConfigurationManager.AppSettings["TICK"].ToString()) * 1000;
        /// <summary>
        /// 数据库执行语句 #DATE# 是执行时间，执行后替换成当前时间
        /// </summary>
        private readonly string configSQL = ConfigurationManager.AppSettings["SQL"].ToString();
        /// <summary>
        /// 多少条存一个文件
        /// </summary>
        private readonly int counts = int.Parse(ConfigurationManager.AppSettings["COUNTS"].ToString());
        /// <summary>
        /// 公司名称缩写
        /// </summary>
        private readonly string companyName = ConfigurationManager.AppSettings["COMPANYNAME"].ToString();
        /// <summary>
        /// 公司中文名称
        /// </summary>
        private readonly string chinaName = ConfigurationManager.AppSettings["CHINANAME"].ToString();
        /// <summary>
        /// 优先级
        /// </summary>
        private readonly byte PriorNo = byte.Parse(ConfigurationManager.AppSettings["PriorNo"].ToString());
        /// <summary>
        /// 队列名称
        /// </summary>
        private readonly string QueName = ConfigurationManager.AppSettings["QueName"].ToString();
        /// <summary>
        /// 程序编号
        /// </summary>
        private readonly int ProgramNO = int.Parse(ConfigurationManager.AppSettings["ProgramNO"].ToString());
        #endregion


        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {


            MessageBox.Show((int.Parse(ConfigurationManager.AppSettings["TICK"].ToString()) * 1000).ToString());
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            MessageBox.Show(ConfigurationManager.AppSettings["DATE"].ToString());
            config.AppSettings.Settings["DATE"].Value = DateTime.Now.ToString();
            config.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection("appSettings");


            ISQLManager mger;
            //mger = new MSSQLHelper();
            //string TypeName = "Catch.SQLServerDAL.MSSQLHelper";
            mger = (ISQLManager)Assembly.Load(Path).CreateInstance(TypeName);//反射创建
            // Assembly sd = Assembly.Load("Catch.SQLServerDAL");

            // object ob = sd.CreateInstance("Catch.SQLServerDAL.MSSQLHelper");

            //Assembly.CreateQualifiedName();
            CheckMessage check = new CheckMessage();
            DataSet ds = mger.GetDateSet(" select * from db1");
            DateTime dt = DateTime.Now;
            if (ds.Tables != null && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    for (int j = 0; j < 1; j++)
                    {
                        string ss = psmd5(ds.Tables[0].Rows[i][0].ToString() +
                              ds.Tables[0].Rows[i][1].ToString() +
                                ds.Tables[0].Rows[i][2].ToString() +
                                  ds.Tables[0].Rows[i][3].ToString() +
                                    ds.Tables[0].Rows[i][4].ToString() +
                                      ds.Tables[0].Rows[i][5].ToString() +
                                        ds.Tables[0].Rows[i][6].ToString() +
                                          ds.Tables[0].Rows[i][7].ToString() +
                                            ds.Tables[0].Rows[i][8].ToString() +
                                              ds.Tables[0].Rows[i][9].ToString() +
                                                ds.Tables[0].Rows[i][10].ToString());
                        string sj = psmd5(ds.Tables[0].Rows[i][0].ToString() +
                            ds.Tables[0].Rows[i][1].ToString() +
                              ds.Tables[0].Rows[i][2].ToString() +
                                ds.Tables[0].Rows[i][3].ToString() +
                                  ds.Tables[0].Rows[i][4].ToString() +
                                    ds.Tables[0].Rows[i][5].ToString() +
                                      ds.Tables[0].Rows[i][6].ToString() +
                                        ds.Tables[0].Rows[i][7].ToString() +
                                          ds.Tables[0].Rows[i][8].ToString() +
                                            ds.Tables[0].Rows[i][9].ToString() +
                                              ds.Tables[0].Rows[i][10].ToString());
                        if (ss == sj)
                        {
                            //DataSet ds1 = mger.GetDateSet(" select * from db2");

                            check.GetDataSet();
                        }
                        //ds1.Tables[0].Select(" kid ='" + ds1.Tables[0].Rows[0][0].ToString() + "'");
                        //mger.GetDateSet("INSERT INTO DB1 ( M, Q, a, df, afd, 字段1, 字段2, 字段3, 字段4, 字段5 )SELECT [dfgdsfg] AS 表达式10, [sdfgsd] AS 表达式9, [sdfgs] AS 表达式8, [dfg] AS 表达式7, [sdfg] AS 表达式6, [sdfg] AS 表达式5, [fgdfg] AS 表达式4, [sdfsdg] AS 表达式3, [sdf] AS 表达式2, [fsf] AS 表达式1;");
                    }
                }
            }

            TimeSpan df = DateTime.Now - dt;


        }

        #region  密码加密
        public static string psmd5(string password)//MD5加密
        {
            System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
            byte[] bytes = new byte[16];
            System.Text.ASCIIEncoding asc = new System.Text.ASCIIEncoding();
            bytes = md5.ComputeHash(asc.GetBytes(password));
            return Convert.ToBase64String(bytes);
        }
        #endregion


        /// <summary> /// 加密文件 /// </summary> 
        /// <param name="sInputFile">源文件</param> 
        /// <param name="sOutputFile">加密过后的文件</param> 
        /// <param n
        /// <summary>
        /// 加密文件
        /// </summary>
        /// <param name="sInputFile">源文件</param>
        /// <param name="sOutputFile">加密过后的文件</param>
        /// <param name="sKey">密钥</param>
        /// <param name="sMsg">返回信息</param>
        /// <returns>是否成功</returns>
        public static bool EncryptFile(string sInputFilename, string sOutputFilename, string sKey, out string sMsg)
        {
            bool IsSuccess = true;
            FileStream fsInput = null;
            FileStream fsEncrypted = null;
            CryptoStream cryptostream = null;
            try
            {
                fsInput = new FileStream(sInputFilename, FileMode.Open, FileAccess.Read);

                fsEncrypted = new FileStream(sOutputFilename,
                                                        FileMode.Create,
                                                        FileAccess.Write);
                DESCryptoServiceProvider DES = new DESCryptoServiceProvider();
                DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
                DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
                ICryptoTransform desencrypt = DES.CreateEncryptor();
                cryptostream = new CryptoStream(fsEncrypted,
                                                            desencrypt,
                                                            CryptoStreamMode.Write);

                byte[] bytearrayinput = new byte[fsInput.Length];
                fsInput.Read(bytearrayinput, 0, bytearrayinput.Length);
                cryptostream.Write(bytearrayinput, 0, bytearrayinput.Length);
                cryptostream.Close();
                fsInput.Close();
                fsEncrypted.Close();
                sMsg = "成功";
                return true;
            }
            catch (Exception ex)
            {
                sMsg = ex.Message;
                IsSuccess = true;
            }
            finally
            {
                try
                {
                    if (cryptostream != null) cryptostream.Close();
                    if (fsInput != null) fsInput.Close();
                    if (fsEncrypted != null) fsEncrypted.Close();
                }
                catch
                {

                }
            }
            return IsSuccess;
        }



        public static bool DecryptFile(string sInputFilename, string sOutputFilename, string sKey, out string sMsg)
        {
            FileStream fsread = null;
            StreamWriter fsDecrypted = null;
            bool isSuccess = true;
            try
            {
                DESCryptoServiceProvider DES = new DESCryptoServiceProvider();
                //A 64 bit key and IV is required for this provider.
                //Set secret key For DES algorithm.
                DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
                //Set initialization vector.
                DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey);

                //Create a file stream to read the encrypted file back.
                fsread = new FileStream(sInputFilename,
                                               FileMode.Open,
                                               FileAccess.Read);
                //Create a DES decryptor from the DES instance.
                ICryptoTransform desdecrypt = DES.CreateDecryptor();
                //Create crypto stream set to read and do a
                //DES decryption transform on incoming bytes.
                CryptoStream cryptostreamDecr = new CryptoStream(fsread,
                                                             desdecrypt,
                                                             CryptoStreamMode.Read);
                //Print out the contents of the decrypted file.
                fsDecrypted = new StreamWriter(sOutputFilename);
                fsDecrypted.Write(new StreamReader(cryptostreamDecr).ReadToEnd());
                fsDecrypted.Flush();
                fsDecrypted.Close();
                sMsg = "解密成功";
            }
            catch (Exception ex)
            {
                sMsg = ex.Message;
                isSuccess = false;
            }
            finally
            {
                try
                {
                    if (fsread != null) fsread.Close();
                    if (fsDecrypted != null) fsDecrypted.Close();
                }
                catch
                {
                }
            }
            return isSuccess;
        }


        private void button2_Click(object sender, EventArgs e)
        {
            //XmlDocument   xmldoc   =   new   XmlDocument();     

            //XmlTextReader r = new XmlTextReader("C:\\MyFolder\\ProductWithDTD.xml");
            //XmlValidatingReader v = new XmlValidatingReader(r);
            //v.ValidationType = ValidationType.DTD;




            XmlDocument xmldoc = new XmlDocument();
            //加入XML的声明段落,<?xml version="1.0" encoding="gb2312"?>
            XmlDeclaration xmldecl;
            xmldecl = xmldoc.CreateXmlDeclaration("1.0", "gb2312", null);
            xmldoc.AppendChild(xmldecl);
            XmlDocumentType doctype = xmldoc.CreateDocumentType("SOGenericInterchange", null, "SOGenericInterchange.dtd", null);
            xmldoc.AppendChild(doctype);
            //加入一个根元素
            XmlElement xmlelem = xmldoc.CreateElement("", "Employees", "");
            xmldoc.AppendChild(xmlelem);
            //加入另外一个元素
            for (int i = 1; i < 3; i++)
            {

                XmlNode root = xmldoc.SelectSingleNode("Employees");//查找<Employees> 
                XmlElement xe1 = xmldoc.CreateElement("Node");//创建一个<Node>节点 
                xe1.SetAttribute("genre", "李赞红");//设置该节点genre属性 
                xe1.SetAttribute("ISBN", "2-3631-4");//设置该节点ISBN属性 

                XmlElement xesub1 = xmldoc.CreateElement("title");
                xesub1.InnerText = "CS从入门到精通";//设置文本节点 
                xe1.AppendChild(xesub1);//添加到<Node>节点中 
                XmlElement xesub2 = xmldoc.CreateElement("author");
                xesub2.InnerText = "候捷";
                xe1.AppendChild(xesub2);
                XmlElement xesub3 = xmldoc.CreateElement("price");
                xesub3.InnerText = "58.3";
                xe1.AppendChild(xesub3);

                root.AppendChild(xe1);//添加到<Employees>节点中 
            }
            //保存创建好的XML文档
            xmldoc.Save("data.xml");

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            if (!Directory.Exists(savepath))
            {
                Directory.CreateDirectory(savepath);
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {

                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                string datetimestring = DateTime.Now.ToString();
                string olddatetimestring = ConfigurationManager.AppSettings["DATE"].ToString();
                string sqlstring = configSQL.Replace("#DATE#", olddatetimestring);
                config.AppSettings.Settings["DATE"].Value = datetimestring;
                config.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("appSettings");
                ISQLManager mger;
                mger = (ISQLManager)Assembly.Load(Path).CreateInstance(TypeName);//反射创建
                DataSet ds = mger.GetDateSet(sqlstring);
                if (ds.Tables != null && ds.Tables[0].Rows.Count > 0)
                {
                    XmlDocument xmldoc = new XmlDocument();
                    //加入XML的声明段落,<?xml version="1.0" encoding="gb2312"?>
                    XmlDeclaration xmldecl;
                    xmldecl = xmldoc.CreateXmlDeclaration("1.0", "gb2312", null);
                    xmldoc.AppendChild(xmldecl);

                    XmlElement xmlelem = xmldoc.CreateElement("", root, "");
                    xmldoc.AppendChild(xmlelem);

                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        XmlNode baseroot = xmldoc.SelectSingleNode(root);//查找<根节点> 
                        XmlElement xe1 = xmldoc.CreateElement(product);//创建一个<产品>节点 

                        for (int j = 0; j < node.Length; j++)
                        {
                            XmlElement xesub1 = xmldoc.CreateElement(node[j]);
                            if (ds.Tables[0].Columns.Count <= j)
                            {
                                xesub1.InnerText = "";
                            }
                            else
                            {
                                xesub1.InnerText = ds.Tables[0].Rows[i][j].ToString();
                            }
                            xe1.AppendChild(xesub1);
                        }
                        baseroot.AppendChild(xe1);//添加到<Employees>节点中 
                    }


                    xmldoc.Save(savepath + DateTime.Now.ToString().Replace(" ", "").Replace(":", "").Replace("-", "") + ".xml");
                }
            }
            catch
            {
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            File.Create(savepath + DateTime.Now.ToString().Replace(" ", "").Replace(":", "").Replace("-", "") + ".date");
        }

        private void button4_Click(object sender, EventArgs e)
        {
            timer1.Start();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            string datetimestring = DateTime.Now.ToString();
            string olddatetimestring = ConfigurationManager.AppSettings["DATE"].ToString();
            string sqlstring = configSQL.Replace("#DATE#", olddatetimestring).Replace("#QYNAME#", chinaName);
            config.AppSettings.Settings["DATE"].Value = datetimestring;
            config.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection("appSettings");
            ISQLManager mger;
            mger = (ISQLManager)Assembly.Load(Path).CreateInstance(TypeName);//反射创建
            DataSet ds = mger.GetDateSet(sqlstring);
            if (ds.Tables != null && ds.Tables[0].Rows.Count > 0)
            {
                XmlDocument xmldoc1 = new XmlDocument();
                //加入XML的声明段落,<?xml version="1.0" encoding="gb2312"?>
                XmlDeclaration xmldecl1;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (i % counts == 0)
                    {
                        xmldoc1 = new XmlDocument();
                        xmldecl1 = xmldoc1.CreateXmlDeclaration("1.0", "gb2312", null);
                        xmldoc1.AppendChild(xmldecl1);
                        XmlElement xmlelem = xmldoc1.CreateElement("", root, "");
                        xmldoc1.AppendChild(xmlelem);
                    }

                    XmlNode baseroot = xmldoc1.SelectSingleNode(root);//查找<根节点> 
                    XmlElement xe1 = xmldoc1.CreateElement(product);//创建一个<产品>节点 
                    for (int j = 0; j < node.Length; j++)
                    {
                        XmlElement xesub1 = xmldoc1.CreateElement(node[j]);
                        if (ds.Tables[0].Columns.Count <= j)
                        {
                            xesub1.InnerText = "";
                        }
                        else
                        {
                            xesub1.InnerText = ds.Tables[0].Rows[i][j].ToString();
                        }
                        xe1.AppendChild(xesub1);

                        baseroot.AppendChild(xe1);//添加到<根>节点中 
                        if ((j + 1 == node.Length) && ((i + 1) % counts == 0 && i != 0) || ds.Tables[0].Rows.Count == i + 1)
                        {
                            //根据时间保存文件名
                            string filename = companyName + DateTime.Now.ToString().Replace(" ", "").Replace(":", "").Replace("-", "") + i.ToString() + ".xml";
                            xmldoc1.Save(savepath + filename);

                            //TLQMSG_INFO msg = new TLQMSG_INFO();

                            //TLQ_ID id = new TLQ_ID();
                            //tlqInterface.tlq_conn(id);
                            //tlqInterface.tlq_login (
                        }
                    }
                }
                //}
                //else
                //{
                //    XmlDocument xmldoc = new XmlDocument();
                //    //加入XML的声明段落,<?xml version="1.0" encoding="gb2312"?>
                //    XmlDeclaration xmldecl;
                //    xmldecl = xmldoc.CreateXmlDeclaration("1.0", "gb2312", null);
                //    xmldoc.AppendChild(xmldecl);

                //    XmlElement xmlelem = xmldoc.CreateElement("", root, "");
                //    xmldoc.AppendChild(xmlelem);


                //    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                //    {
                //        XmlNode baseroot = xmldoc.SelectSingleNode(root);//查找<根节点> 
                //        XmlElement xe1 = xmldoc.CreateElement(product);//创建一个<产品>节点 

                //        for (int j = 0; j < node.Length; j++)
                //        {
                //            XmlElement xesub1 = xmldoc.CreateElement(node[j]);
                //            if (ds.Tables[0].Columns.Count <= j)
                //            {
                //                xesub1.InnerText = "";
                //            }
                //            else
                //            {
                //                xesub1.InnerText = ds.Tables[0].Rows[i][j].ToString();
                //            }
                //            xe1.AppendChild(xesub1);
                //        }
                //        baseroot.AppendChild(xe1);//添加到<根>节点中 
                //    }
                //    //根据时间保存文件名
                //    xmldoc.Save(savepath + DateTime.Now.ToString().Replace(" ", "").Replace(":", "").Replace("-", "") + ".xml");
                //}
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            //TLQMSG_INFO msg = new TLQMSG_INFO();
            //bool connected = false;
            //  this get
            //Process myProcess = Process.GetProcessesByName("ChachMessage")[0];
            //Process myProcess = Process.GetCurrentProcess();
            //int thisid = myProcess.Id;
            //System.Windows.Forms.MessageBox.Show(myProcess.Id + ":" + myProcess.ProcessName);


            TLQ_ID tlqId = new TLQ_ID();
        
            bool online = tlqInterface.tlq_login(ref tlqId, ProgramNO, 0) >= 0;
            if (online)
            {
                string filename = textBox1.Text;// "readme.txt";
                TLQMSG_INFO msginfo = new TLQMSG_INFO();
                msginfo.CompressFlag = 0;//1压缩，0不压缩
                msginfo.Expiry = -1;//生命周期-1，为无限若Expiry>0, 要求发送消息的生命周期大于[system]中的核心检测周期TimeV
                msginfo.MsgLen = filename.Length;//消息的长度,若MsgType 为BUF_MSG 类型时，则为消息内容；若MsgType 为FILE_MSG 类型时，则为文件消息的文件名。
                msginfo.MsgType = 1;//文件为1，数据报为0
                msginfo.RemoveFileFlag = 1;//1删除原文件，0不删除
                msginfo.CryptFlag = 0;//0不加密，1加密
                msginfo.PriorNo = PriorNo;//配置的优先及
                msginfo.QueName = QueName;//消息队列名

                int ti = tlqInterface.tlq_putmsg(ref tlqId, ref msginfo, filename, 0);
                MessageBox.Show(ti.ToString());

                tlqInterface.tlq_logout(ref tlqId);
            }

        }

        private void button7_Click(object sender, EventArgs e)
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            string datetimestring = DateTime.Now.ToString();
            string olddatetimestring = ConfigurationManager.AppSettings["DATE"].ToString();
            string sqlstring = configSQL.Replace("#DATE#", olddatetimestring).Replace("#QYNAME#", chinaName);
            config.AppSettings.Settings["DATE"].Value = datetimestring;
            config.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection("appSettings");
            ISQLManager mger;
            mger = (ISQLManager)Assembly.Load(Path).CreateInstance(TypeName);//反射创建
            DataSet ds = mger.GetDateSet(sqlstring);
            if (ds.Tables != null && ds.Tables[0].Rows.Count > 0)
            {
                XmlDocument xmldoc1 = new XmlDocument();
                //加入XML的声明段落,<?xml version="1.0" encoding="gb2312"?>
                XmlDeclaration xmldecl1;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (i % counts == 0)
                    {
                        xmldoc1 = new XmlDocument();
                        xmldecl1 = xmldoc1.CreateXmlDeclaration("1.0", "gb2312", null);
                        xmldoc1.AppendChild(xmldecl1);
                        XmlElement xmlelem = xmldoc1.CreateElement("", root, "");
                        xmldoc1.AppendChild(xmlelem);
                    }

                    XmlNode baseroot = xmldoc1.SelectSingleNode(root);//查找<根节点> 
                    XmlElement xe1 = xmldoc1.CreateElement(product);//创建一个<产品>节点 
                    for (int j = 0; j < node.Length; j++)
                    {
                        XmlElement xesub1 = xmldoc1.CreateElement(node[j]);
                        if (ds.Tables[0].Columns.Count <= j)
                        {
                            xesub1.InnerText = "";
                        }
                        else
                        {
                            xesub1.InnerText = ds.Tables[0].Rows[i][j].ToString();
                        }
                        xe1.AppendChild(xesub1);

                        baseroot.AppendChild(xe1);//添加到<根>节点中 
                        if ((j + 1 == node.Length) && ((i + 1) % counts == 0 && i != 0) || ds.Tables[0].Rows.Count == i + 1)
                        {
                            //根据时间保存文件名
                            string filename = companyName + DateTime.Now.ToString().Replace(" ", "").Replace(":", "").Replace("-", "") + i.ToString() + ".xml";
                            xmldoc1.Save(savepath + filename);
                            SendFile(filename);
                        }
                    }
                }
            }
        }


        /// <summary>
        /// 发送文件
        /// </summary>
        /// <param name="filename"></param>
        private void SendFile(string filename)
        {
            TLQ_ID tlqId = new TLQ_ID();

            bool online = tlqInterface.tlq_login(ref tlqId, ProgramNO, 0) >= 0;
            if (online)
            {
                // string filename = textBox1.Text;// "readme.txt";
                TLQMSG_INFO msginfo = new TLQMSG_INFO();
                msginfo.CompressFlag = 0;//1压缩，0不压缩
                msginfo.Expiry = -1;//生命周期-1，为无限若Expiry>0, 要求发送消息的生命周期大于[system]中的核心检测周期TimeV
                msginfo.MsgLen = filename.Length;//消息的长度,若MsgType 为BUF_MSG 类型时，则为消息内容；若MsgType 为FILE_MSG 类型时，则为文件消息的文件名。
                msginfo.MsgType = 1;//文件为1，数据报为0
                msginfo.RemoveFileFlag = 1;//1删除原文件，0不删除
                msginfo.CryptFlag = 0;//0不加密，1加密
                msginfo.PriorNo = PriorNo;//配置的优先及
                msginfo.QueName = QueName;//消息队列名

                int ti = tlqInterface.tlq_putmsg(ref tlqId, ref msginfo, filename, 0);
                // MessageBox.Show(ti.ToString());

                tlqInterface.tlq_logout(ref tlqId);
            }
        }
    }
}
